package doantotnghiep.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.NamedNativeQuery;

@Entity
@NamedNativeQuery(name="getImportedID", query="call getCurrentImportedID();",resultClass = ImportedMedicament.class)
@Table(name="PhieuNhapHang")
public class ImportedMedicament {
	
	private int id;
	private String importedDate;
	private Staff staff;
   
	@Id
	@GeneratedValue
	@Column(name="MaPNH")
	public int getId() {
		return id;
	}
	
	public void setId(int id) {
		this.id = id;
	}
	
	@Column(name="NgayNhap")
	public String getImportedDate() {
		return importedDate;
	}
	
	public void setImportedDate(String importedDate) {
		this.importedDate = importedDate;
	}
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "MaNV")
	public Staff getStaff() {
		return staff;
	}
	
	public void setStaff(Staff staff) {
		this.staff = staff;
	}

	private Set<ImportedDetail> details = new HashSet<ImportedDetail>();
	
	@OneToMany(mappedBy = "importedMedicament", fetch = FetchType.LAZY) 
	@Fetch(FetchMode.JOIN)
	public Set<ImportedDetail> getDetails() {
		return details;
	}
	public void setDetails(Set<ImportedDetail> details) {
		this.details = details;
	}	
}
